<template>
  <div class="tree">
    <el-card style="height:100%">
      <h3 class="title">问题场景</h3>
      <el-tree
        ref="tree"
        class="filter-tree"
        :data="treeData"
        :props="defaultProps"
        default-expand-all
        node-key="id"
        :filter-node-method="filterNode"
        @node-click="change"
      />

    </el-card>
  </div>
</template>
<script>
import { lists } from '@/api/decision/task'
// import store from '@/store'
export default {

  data() {
    return {
      filterText: '',
      treeData: [
      ],
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    }
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val)
    }
  },
  created() {
    this.getList()
  },

  methods: {
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },
    /** 查询预案列表 */
    getList() {
    // this.loading = true
      lists(null).then(response => {
        this.treeData = response.rows
      })
    },
    change(val) {
      this.$emit('changeTree', val)
      // this.$store.commit('plan/SET_TREE_NODE', val)
    }
  }

}
</script>
<style lang="scss" scoped>
.tree{
  margin-left:18px;
  width:200px;

}

.title{
  margin-bottom: 10px;
}
</style>
